var express = require('express');
var router = express.Router();
var db = require('./conn');//先引入数据库链接

/* GET home page. */
router.get('/',function(req, res) {
  	
	var userlogin = req.param('userlogin');
	var passlogin = req.param('passlogin');
	db.pool.getConnection(function(err, connection) {
	    var  sql = 'select * from userinfo where UserName=? and UserPass=?';
	    var  sql_val = [userlogin,passlogin];

	    connection.query( sql,sql_val, function(error, res) {
	        if(res.length!=0){
	            res.render('index', {title:"welcome",name:userlogin,pass:passlogin});
	        }else{
	            // resLogin.render('login', { title:"登陆页面"});
	            res.render('newUser', { title:"欢迎新成员",result:''});
	        }
	    });
	    connection.release();
	});
});

module.exports = router;
